
import { Component } from 'vue-property-decorator';
import { VueLifeCycleProcessing,EditorBase } from 'ibiz-vue';
import { Prop } from 'vue-property-decorator';

/**
 * 表格文件上传控件插件类
 *
 * @export
 * @class RowFileUpload
 * @extends {EditorBase}
 */
@Component({})
@VueLifeCycleProcessing()
export class RowFileUpload extends EditorBase {
    
        /**
     * 是否忽略表单项值变化
     *
     * @type {boolean}
     * @memberof AppDefaultEditor
     */
    @Prop() public ignorefieldvaluechange?:any

    /**
     * 编辑器初始化
     *
     * @memberof UploadEditor
     */
     public async initEditor() {
        await super.initEditor();
        this.customProps.uploadparams = this.editorInstance.editorParams?.['uploadparams'];
        this.customProps.exportparams = this.editorInstance.editorParams?.['exportparams'];
        this.customProps.limit = this.editorInstance.editorParams?.['limit'] ? JSON.parse(this.editorInstance.editorParams['limit'] as string) : 9999;
        this.customProps.accept = this.editorInstance.editorParams?.['accept'] ? this.editorInstance.editorParams['accept'] : '*';
    }

    /**
     * 绘制内容
     *
     * @returns {*}
     * @memberof UploadEditor
     */
     public render(): any {
        this.customProps.formState = this.contextState;
        this.customProps.ignorefieldvaluechange = this.ignorefieldvaluechange;
        return this.$createElement("app-row-file-upload",{
          ref: 'editor',
          props: {
              name: this.editorInstance.name,
              value: this.value,
              disabled: this.disabled,
              context: this.context,
              viewparams: this.viewparams,
              data: JSON.stringify(this.contextData),
              ...this.customProps,
          },
          on: { formitemvaluechange: this.editorChange },
          style: this.customStyle
      })
    }
}
